#ifndef __HTTPSERVER_H_
#define __HTTPSERVER_H_
#include "KLib.h"
#include "Socket.h"
#include "File.h"
#include "Thread.h"
#include "ScopedLock.h"
SK

typedef struct _HTTPServerOptions
{
    bool localHostOnly;
    u16 localPort;
}HTTPServerOptions;


class HTTPServer
{
protected:
    String root;
    bool localOnly;
    u16 lport;
    Socket *mainSoc;
    Socket *curClient;

    typedef std::list <Thread *>ThreadList;
    ThreadList threads;
    Lock threadLock;

    void addThread (Thread *t);
    void removeThread (Thread *t);


public:
    HTTPServer (const String& rootDir, u16 localPort=80);
    HTTPServer (const String& rootDir, const HTTPServerOptions &options);
    ~HTTPServer ();

    void start (void);

    void _onRequestComplete (Thread *t);
};

EK

#endif